let data = ['张三','李四','王五','赵六']
let lucky = [];

const content = document.querySelector('#content')
for (let i = 0; i < data.length; i++) {
    let lis = document.createElement('div')
    lis.innerHTML = `
    <div class="cell">${data[i]}</div>
    `
    content.appendChild(lis)
}

const button = document.querySelector('button')
const cell = document.querySelectorAll('.cell')

let setdata = []
button.addEventListener('click', function () {
    let index = null;
    let obj = setInterval(function () {
        if(index !== null) {
            cell[index].classList.remove("a")
        }
         index = Math.floor(Math.random() * data.length)
        cell[index].classList.add('a')
    }, 50)
    
    setTimeout(function () {
        cell[index].classList.add('current')
        clearInterval(obj)
        while (setdata.includes(data[index])) {
         index = Math.floor(Math.random() * data.length)
        }
        cell[index].classList.add('a')
        setdata.push(data[index]);
        index = null;
    }, 500)
})